package com.bJian.bJIanOJ.judge.codeSandbox.impl;

import cn.hutool.core.io.FileUtil;
import com.bJian.bJIanOJ.judge.codeSandbox.CodeSandbox;
import com.bJian.bJIanOJ.judge.codeSandbox.codeSandboxFactory;
import com.bJian.bJIanOJ.judge.codeSandbox.codeSandboxProxy;
import com.bJian.bJIanOJ.judge.codeSandbox.model.ExecuteCodeRequest;
import com.bJian.bJIanOJ.judge.codeSandbox.model.ExecuteCodeResponse;

import java.util.ArrayList;
import java.util.Arrays;

public class CodeboxTest {
    public static void main(String[] args) {

        String code = "public class Main {\n" +
                "    public static void main(String[] args) {\n" +
                "        String arg = args[0];\n" +
                "        String arg1 = args[1];\n" +
                "\n" +
                "        System.out.println(\"结果：\"+(arg1+arg));\n" +
                "\n" +
                "    }\n" +
                "}\n";
        ArrayList<String> arrayList = new ArrayList<>(Arrays.asList("1 2","2 3","11 22","111 ada1"));

        CodeSandbox exampleCodeSandbox = codeSandboxFactory.newInstanse("");
        exampleCodeSandbox = new codeSandboxProxy(exampleCodeSandbox);
        ExecuteCodeRequest executeCodeRequest = ExecuteCodeRequest
                .builder()
                .code(code)
                .inputList(arrayList)
                .build();
        ExecuteCodeResponse executeCodeResponse = exampleCodeSandbox.executeCode(executeCodeRequest);
        System.out.println(executeCodeResponse);
    }
}
